<template>
  <div class="address">
    <van-nav-bar
      title="我的收货地址"
      left-text="返回"
      right-text="新增地址"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <div class="myAds" v-for="(item, index) in $store.state.addressList" :key="index">
      <div class="ads">
        <h3>{{ item.address }}</h3>
        <p>
          <span>{{ item.name }}</span>
          <span>{{ item.phone }}</span>
        </p>
      </div>
      <div class="revise">
        <van-icon name="edit" size="30" class="edit" @click="revise(item)" />
        
      </div>
    </div>
  </div>
</template>
<script>

export default {
  data() {
    return {
      
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      this.$router.push("/addaddress");
    },
    revise(item){
      this.$router.push('/reviseaddress/'+JSON.stringify(item));
      console.log(JSON.stringify(item));
    }
  },
  mounted() {
  this.$store.dispatch("request_address_list")
  },
};
</script>
<style lang="scss" scoped>
.myAds {
  display: flex;
  justify-content: space-between;
  margin: 20px;
  .ads {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 50px;
    p {
      color: #999;
      span {
        margin-right: 10px;
      }
    }
  }
  .revise {
    .edit {
      line-height: 50px;
    }
  }
}
</style>